#include "BMI088_receive.h"
#include "main.h"

//请注意量程的手动设置一定要与C板统一 在BMI088_receive.h中进行设置

BMI088_Data_t BMI088_Data;//BMI088的数据结构体

const BMI088_Data_t *get_BMI088_data_point(void) //获取BMI088数据指针
{
    return &BMI088_Data;
}

//解析CAN端的BMI088数据 并将数据存入BMI088的数据结构体当中

void CAN_to_BMI088_accel(uint8_t data[8])
{
	if(data == NULL)
    {
        return;
    }
	
    BMI088_Data.accel.raw_x = (int16_t) ((data[0] << 8) | data[1]);
    BMI088_Data.accel.x = BMI088_Data.accel.raw_x * BMI088_ACCEL_SEN;
    
    BMI088_Data.accel.raw_y = (int16_t) ((data[2] << 8)| data[3]);
    BMI088_Data.accel.y = BMI088_Data.accel.raw_y * BMI088_ACCEL_SEN;
    
    BMI088_Data.accel.raw_z = (int16_t) ((data[4] << 8)| data[5]);
    BMI088_Data.accel.z = BMI088_Data.accel.raw_z * BMI088_ACCEL_SEN;
}

void CAN_to_BMI088_gyro(uint8_t data[8])
{
	if(data == NULL)
    {
        return;
    }
	
    BMI088_Data.gyro.raw_x = (int16_t) ((data[0] << 8 )| data[1]);
    BMI088_Data.gyro.x = BMI088_Data.gyro.raw_x * BMI088_GYRO_SEN;
        
	BMI088_Data.gyro.raw_y = (int16_t) ((data[2] << 8 )| data[3]);
    BMI088_Data.gyro.y = BMI088_Data.gyro.raw_y * BMI088_GYRO_SEN;
        
    BMI088_Data.gyro.raw_z = (int16_t) ((data[4] << 8 )| data[5]);
    BMI088_Data.gyro.z = BMI088_Data.gyro.raw_z * BMI088_GYRO_SEN;
}

